// ----------------------------------------------------------------------
//  Jack McCaffery
//  11-30-2014
// ----------------------------------------------------------------------

#include "topicModel/fixedParameters.H"
#include "topicModel/generalParameters.H"
#include "topicModel/boundedParameters.H"
#include "topicModel/multinomialParameters.H"


class BigTests
{
	Q_OBJECT;

private slots:
	/// \brief Test bounded parameters funtionality
	void test_bounded ();

	/// \brief Test constrained parameters
	void test_multinomial ();

private:
	/// \brief Test parameters
	BoundedParameters b;

	/// \brief Test parameters
	BoundedParameters c;

	/// \brief Test parameters
	MultinomialParameters m;

	/// \brief Test parameters
	MultinomialParameters n;

	/// \brief Gradient to apply
	FixedParameters gradient;
}


void BigTests::init_testCases ()
{
	b.data ().resize (2, 3);
	b.setLowerBound (0);
	b.setUpperBound (1);

	b[0][0] = 0.5;
	b[0][1] = 0.7;
	b[0][2] = 0.1;
	b[1][0] = 0;
	b[1][1] = 0;
	b[1][2] = 0.9;

	c.data ().resize (2, 3);
	c.setLowerBound (-1000);
	c.setUpperBound (100);

	c[0][0] = -100;
	c[0][1] = 100;
	c[0][2] = 20;
	c[1][0] = 1.5;
	c[1][1] = -700;
	c[1][2] = 0;

	m.data ().resize (2, 3);

	m[0][0] = 0.2;
	m[0][1] = 0.2;
	m[0][2] = 0.6;
	m[1][0] = 0.01;
	m[1][1] = 0.33;
	m[1][2] = 0.66;

	n.data ().resize (2, 3);
	n.setSumValue (10);

	n[0][0] = 0;
	n[0][1] = 5;
	n[0][2] = 5;
	n[1][0] = 1;
	n[1][1] = 2.5;
	n[1][2] = 6.5;
}


void BigTests::testGeneral ()
{
}


void BigTests::testBounded ()
{
	BoundedParameters test;

	test = b;
	test.applyGradient (gradient, 0);

	QVERIFY (test == b);

	test = b;
	test.applyGradient (gradient, -0.1);

	QVERIFY (test[0][0] == 0.4);
	QVERIFY (test[0][1] == 0.5);
	QVERIFY (test[0][2] == 0);
	QVERIFY (test[1][0] == 1);
	QVERIFY (test[1][1] == 0);
	QVERIFY (test[1][2] == 0);

	test = c;
	test.applyGradient (gradient, -350);

	QVERIFY (test[0][0] == -450);
	QVERIFY (test[0][1] == -600);
	QVERIFY (test[0][2] == -1000);
	QVERIFY (test[1][0] == 100);
	QVERIFY (test[1][1] == 100);
	QVERIFY (test[1][2] == 100);
}


void BigTests::testMultinomial ()
{
	MultimonialParameters test;

	test = m;
	test.applyGradient (gradient, 0);

	QVERIFY (test == m);
}


void BigTests::testMixed ()
{


}
